package cn.itcast.hotel.web.controller;


import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import cn.itcast.hotel.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/hotel")
public class HotelController {
    @Autowired
    private IHotelService hotelService;

    @PostMapping("/list")
    public PageResult list(@RequestBody RequestParams requestParams){
        return hotelService.queryList(requestParams);
    }

    //localhost:8089/hotel/filters
    @PostMapping("/filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams requestParams){
        return hotelService.filters(requestParams);
    }

    @GetMapping("/suggestion")
    public List<String> suggestion(@RequestParam("key") String key){
        return hotelService.getSuggestion(key);
    }
}
